package com.lifesaftypower.activity;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;
import org.xmlpull.v1.XmlPullParserException;

import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;

import com.lifesaftypower.product.ProductCategory;
import com.lifesaftypower.product.ProductRepo;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	public void testClick(View view) throws ParserConfigurationException,
			SAXException, IOException, XmlPullParserException {
		// Intent intent = new Intent(this, ProductListActivity.class);

		AssetManager assetManager = getAssets();
		InputStream ins = null;

		ins = assetManager.open("lifesaftypower.xml");

		ArrayList<ProductCategory> categories = ProductRepo.Load(ins);

		Intent intent = new Intent(this, PortalActivity.class);
		// intent.putExtra(ProductCategoryActivity.INTENT_CATEGORY, categories);
		startActivity(intent);
	}

	public void productListClick(View view) {
		Intent intent = new Intent(this, ProductListActivity.class);
	
		startActivity(intent);
	}
}
